package cn.edu.xmu.orderpayment.order.model.enums;


import java.util.HashMap;
import java.util.Map;

/**
 * @author Yujie Lin
 * @date 2021/12/8 19:39
 */
public enum OrderState {

        WAIT_PAY(100, "待付款"),
        NEW_ORDER(101, "新订单"),
        WAIT_REST(102, "待支付尾款"),
        WAIT_DELIVER(200, "待发货"),
        HAS_PAYED(201,"付款完成"),
        WAIT_GROUP(202,"待成团"),
//        DIVIDED(203,"已分单"),
        HAS_DELIVERED(300,"已发货"),
        COMPLETED(400,"已完成"),
        HAS_CANCELED(500,"已取消"),
        WAIT_REFUND(501,"待退款"),
        HAS_REFUNDED(502,"已退款");

        private static final Map<Integer, OrderState> ORDER_STATE_MAP;
        static {
            ORDER_STATE_MAP = new HashMap();
            for (OrderState enum1 : values()) {
                ORDER_STATE_MAP.put(enum1.code, enum1);
            }
        }
        private int code;
        private String description;
        OrderState(int code, String description) {
            this.code = code;
            this.description = description;
        }
        public static OrderState getOrderStateByCode(Integer code) {
            return ORDER_STATE_MAP.get(code);
        }
        public Integer getCode() {
            return code;
        }
        public String getDescription() {
            return description;
        }

}
